package com.rt.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.rt.common.annotation.Log;
import com.rt.common.core.controller.BaseController;
import com.rt.common.core.domain.AjaxResult;
import com.rt.common.enums.BusinessType;
import com.rt.system.domain.RtExamPaperQuestions;
import com.rt.system.service.IRtExamPaperQuestionsService;
import com.rt.common.utils.poi.ExcelUtil;
import com.rt.common.core.page.TableDataInfo;

/**
 * 试卷试题关联Controller
 * 
 * @author Yg
 * @date 2022-05-09
 */
@RestController
@RequestMapping("/system/examquestions")
public class RtExamPaperQuestionsController extends BaseController
{
    @Autowired
    private IRtExamPaperQuestionsService rtExamPaperQuestionsService;

    /**
     * 查询试卷试题关联列表
     */
    @PreAuthorize("@ss.hasPermi('system:examquestions:list')")
    @GetMapping("/list")
    public TableDataInfo list(RtExamPaperQuestions rtExamPaperQuestions)
    {
        startPage();
        List<RtExamPaperQuestions> list = rtExamPaperQuestionsService.selectRtExamPaperQuestionsList(rtExamPaperQuestions);
        return getDataTable(list);
    }

    /**
     * 导出试卷试题关联列表
     */
    @PreAuthorize("@ss.hasPermi('system:questions:export')")
    @Log(title = "试卷试题关联", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RtExamPaperQuestions rtExamPaperQuestions)
    {
        List<RtExamPaperQuestions> list = rtExamPaperQuestionsService.selectRtExamPaperQuestionsList(rtExamPaperQuestions);
        ExcelUtil<RtExamPaperQuestions> util = new ExcelUtil<RtExamPaperQuestions>(RtExamPaperQuestions.class);
        return util.exportExcel(list, "试卷试题关联数据");
    }

    /**
     * 获取试卷试题关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:questions:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(rtExamPaperQuestionsService.selectRtExamPaperQuestionsById(id));
    }

    /**
     * 新增试卷试题关联
     */
    @PreAuthorize("@ss.hasPermi('system:questions:add')")
    @Log(title = "试卷试题关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RtExamPaperQuestions rtExamPaperQuestions)
    {
        return toAjax(rtExamPaperQuestionsService.insertRtExamPaperQuestions(rtExamPaperQuestions));
    }

    /**
     * 修改试卷试题关联
     */
    @PreAuthorize("@ss.hasPermi('system:questions:edit')")
    @Log(title = "试卷试题关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RtExamPaperQuestions rtExamPaperQuestions)
    {
        return toAjax(rtExamPaperQuestionsService.updateRtExamPaperQuestions(rtExamPaperQuestions));
    }

    /**
     * 删除试卷试题关联
     */
    @PreAuthorize("@ss.hasPermi('system:questions:remove')")
    @Log(title = "试卷试题关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rtExamPaperQuestionsService.deleteRtExamPaperQuestionsByIds(ids));
    }
}
